<?php


namespace restphp\utils;


class RestHttpResponseUtils {
    private static $_privateX = array();
    public static function addPrivate($privateX) {
        self::$_privateX[] = $privateX;
    }
    public static function removeXHeader() {
        $arrNewHeaders = array();

        foreach (headers_list() as $strHead) {
            if (RestStringUtils::startWith($strHead, 'X')) {
                $arrHead = explode(':', $strHead);
                $strHeadKey = trim($arrHead[0]);
                if (!in_array($strHeadKey, self::$_privateX)) {
                    continue;
                }
            }
            $arrNewHeaders[] = $strHead;
        }

        header_remove();
        foreach ($arrNewHeaders as $strHead) {
            header($strHead);
        }
    }
}